<%@ page contentType="text/html;charset=utf-8" language="java" import="java.sql.*,java.util.*" errorPage="" %>
<script src="jquery-latest.js"></script>

<HTML>
<HEAD>
<TITLE>UseCase System</TITLE>
<script language="javascript">
<!--

//-->
</script>
</HEAD>

<BODY>

<p> 
<jsp:useBean id="DBCon" class="test.DBCon"/>
    <% Connection conn = null;
	conn = DBCon.getInstance().getConnection();
    Statement stmt = null;
	Statement stmt2 = null;
    stmt = conn.createStatement();
	stmt2 = conn.createStatement();
	String sql1 = "SELECT distinct Use_case_ID FROM usecase WHERE account_number = '" + session.getAttribute("userid") + "'";
    ResultSet rs = stmt.executeQuery(sql1);  
    int i=1;
%>

<script>
function ChangeSelect(usecaseid,usecasetype)
{ 
  val = usecaseid.options[usecaseid.options.selectedIndex].value;
  
 <%while(rs.next()){  
  String SQL2 = "SELECT * FROM usecase WHERE account_number = '" + session.getAttribute("userid") + "' and Use_case_ID ='" +rs.getString("Use_case_ID") + "'";
  ResultSet rs2 = stmt2.executeQuery(SQL2); 
  %>
  if (val == '<%=rs.getString("Use_case_ID")%>')
  {
    
    <%while(rs2.next()){
    i++;
    }%>
    usecasetype.length = <%=i%>; 
    <%
    i=1;
    rs2.first();
    do{%>
    usecasetype.options[<%=i%>].value = '<%=rs2.getString("Case_Type")%>'; 
	usecasetype.options[<%=i%>].text = '<%=rs2.getString("Case_Type")%>';
    <%
    i++;
    }while(rs2.next());
    i=1;%>
  }
  <%}
  rs.first();%>
}
function changequery()
{
  var but = document.getElementById('submit1');
  
  but.disabled = false;	
}
</script>

<form name="selection" action="session2.jsp">
  <p>UseCase_ID</font> :
    <select name=usecaseid onChange="ChangeSelect(document.selection.usecaseid,document.selection.usecasetype)" size="1">
      <option>==============</option>
      <%do{%>
      <option value="<%=rs.getString("Use_case_ID")%>"><%=rs.getString("Use_case_ID")%></option>
      <%}while(rs.next());%>
    </select>
 UseCase_Type :</font> 
 <SELECT name=usecasetype onChange="changequery()" >
    <option>==============</option>
</SELECT>
  </p>
  <p>
    <INPUT type="submit" value=" query " name=submit1 disabled="disabled">
	<input type="button" value=" return menu" onClick="self.location.href='member_login.jsp'"/>
  </p>
</form>
